﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="VipHouses.aspx.cs" Inherits="NEWS.Admin.VipHouses" %>
<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
        function confirmAction()
         {
            if(confirm('Bạn có chắc chắn muốn xóa???'))
            {
                // you clicked the OK button.
                // you can allow the form to post the data.
                return true;
            }
            else 
                // you clicked the Cancel button.
                // you can disallow the form submission.
                return false;
         }
</script>
<script type="text/javascript">
    function SelectAll(CheckBox)
    {
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        for(var iCount = 0; iCount < Inputs.length; ++iCount)
        {                
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0)
                Inputs[iCount].checked = CheckBox.checked;   
        }
    }
    function SelectDeSelectHeader(CheckBox)
    {        
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var TargetHeaderControl = "chkSelectAll";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        var flag = false;
        var HeaderCheckBox;
        for(var iCount = 0; iCount < Inputs.length ; ++iCount)
        {    
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetHeaderControl,0) >= 0)            
                HeaderCheckBox = Inputs[iCount];            
            if(Inputs[iCount] != CheckBox && Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0 && Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)
            {            
                if(CheckBox.checked)
                {                    
                    if(!Inputs[iCount].checked)                    
                    {                    
                        flag = false;
                        HeaderCheckBox.checked = false;                       
                        return;
                    }
                    else
                        flag = true;                    
                }
                else if(!CheckBox.checked)                
                    HeaderCheckBox.checked = false;                                                       
            }            
        }                      
        if(flag)        
            HeaderCheckBox.checked = CheckBox.checked        
    }
</script>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
     <ContentTemplate>
           <asp:Panel ID="PanelDasboard" runat="server"  Visible="true">
            <div class="dashboard">
                <h2 class="ico_mug">
                    Danh sách tin Vips</h2>
                    
                    <div style="width:100%; margin-bottom:10px;">
                    <p style="margin-right:10px;float:left;">
                        &nbsp;</p>
                    <p style="margin-right:10px;float:left;"><asp:LinkButton ID="btndangtin" 
                            runat="server" Font-Bold="True" ForeColor="Blue" Visible="true" 
                            onclick="btndangtin_Click">Đăng tin</asp:LinkButton></p>
                    <p><asp:LinkButton ID="btnxoatin" runat="server" Font-Bold="True" ForeColor="Blue" 
                            Visible="true" onclick="btnxoatin_Click" OnClientClick="javascript:return confirmAction();">Xóa 
                        Tin Được Chọn</asp:LinkButton></p>
                </div>
                <div>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataKeyNames="VipHouseID"
                        DataSourceID="ObjectDataSource1" Width="100%" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                        ForeColor="#333333" GridLines="None" 
                        onrowdatabound="GridView1_RowDataBound" 
                        onrowcommand="GridView1_RowCommand">
                        <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                        <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:CommandField ButtonType="Image" SelectImageUrl="~/Admin/img/edit.png" 
                                ShowSelectButton="True" >
                                <ItemStyle Width="50px" />
                            </asp:CommandField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtxemtin" runat="server" CausesValidation="False">Xem</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkSelect" runat="server" />
                                </ItemTemplate>
                                <HeaderTemplate>
                                 <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this);" />                                
                                </HeaderTemplate>
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle Width="15px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="VipHouseID" HeaderText="Mã tin" ReadOnly="True" 
                                SortExpression="VipHouseID" InsertVisible="False" >
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="NewsHouseID" HeaderText="Mã tin nhà đất" 
                                SortExpression="NewsHouseID" FooterText=" " >
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Price" HeaderText="Gía" 
                                SortExpression="Price" Visible="False" >
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Justify" />
                            </asp:BoundField>
                            <asp:BoundField DataField="RegisterDate" HeaderText="Ngày đăng ký" 
                                SortExpression="RegisterDate" DataFormatString="{0:dd/MM/yyyy}">
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Kích hoạt">
                                <ItemTemplate>
                                    <asp:CheckBox ID="kichhoat" runat="server" Enabled="False" 
                                        Checked='<%# Bind("IsActive") %>' />
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#2461BF" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        SelectMethod="GetAllVipHousesBOList" 
                        TypeName="HousingInfo.Library.VipHouseBOList">
                    </asp:ObjectDataSource>
                    <asp:Label ID="messagedelete" runat="server" Font-Bold="True" Font-Size="Small" 
                        ForeColor="Red"></asp:Label>
                    <br />
                </div>
            </div>
       </asp:Panel>
  </ContentTemplate>
 </asp:UpdatePanel>
</asp:Content>
